﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SignalShopBase;

namespace SignalShop
{
    public class SignalRepository
    {
        private Dictionary<string, Signal> signals;

        public event SignalRepositoryHandler SignalAdded;

        public SignalRepository()
        {
            signals = new Dictionary<string, Signal>();
        }

        public Signal Load(string name)
        {
            return signals[name];
        }

        public void Save(string name, Signal signal)
        {
            signals[name] = signal;
            if (SignalAdded != null) SignalAdded(this, SignalRepositoryEvent.SignalAdded);
        }
    }

    public enum SignalRepositoryEvent
    {
        SignalAdded,
        SignalRemoved
    }

    public delegate void SignalRepositoryHandler(SignalRepository source, SignalRepositoryEvent e);
}
